<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script type="text/javascript">
    if(!window.localStorage){
        alert("浏览器不支持localStorage");
//        return false;
    }else{
        var storage=window.localStorage;
//        写入a字段
        storage['a']=1;
        storage.b=2;
        storage.setItem('c',3);
        console.log(typeof storage['a']);
        console.log(typeof storage['b']);
        console.log(typeof storage['c']);
        var data={
            name:'xiongcheng',
            sex:'man',
            age:24
        };
        storage.setItem('data',JSON.stringify(data));
//        将JSON字符串转换成JSON对象输出
        var json = JSON.parse(storage.getItem('data'));
        console.log(json)
    }

</script>

</body>
</html>